package orion.cricScoreCard.Utilities;

import android.content.Context;
import orion.cricScoreCard.Database.DBAdapter;
import orion.cricScoreCard.Entities.BattingPlayer;
import orion.cricScoreCard.Entities.CurrentPlayers;

public class ScoringFunctions {

	public static int overs;

	public static void swap() {
		BattingPlayer temp = CurrentPlayers.getNon_striker();
		CurrentPlayers.setNon_striker(CurrentPlayers.getStriker());
		CurrentPlayers.setStriker(temp);
	}

	public static void setBalls(int overs) {
		ScoringFunctions.overs = overs;

	}

	public static void playerOut(Context context, BattingPlayer _player,
			String _who, String _how) {
		DBAdapter dbAdapter = new DBAdapter(context);
		dbAdapter.insert_batting(_player.get_teamName(),
				_player.get_playerName(), _player.get_out(), _player.get_run()
						+ "", _player.get_ball() + "", _player.get_four() + "",
				_player.get_six() + "");
		if (CurrentPlayers.getStriker().equals(_player)) {
			CurrentPlayers.setStriker(new BattingPlayer());
		} else {
			CurrentPlayers.setNon_striker(new BattingPlayer());
		}
	}
}
